MacroSubstitutionDelegate Delegate (original) (raw)

Summary

Provides a delegate type to be used to process a macro.

Syntax

public delegate string MacroSubstitutionDelegate( T _item_, string _name_, object[] _parameters_ )

generic<typename _T_> public delegate String^ MacroSubstitutionDelegate( _T^_ _item_, String^ _name_, ... array<Object^>^ _parameters_ )

Parameters

_item_The user data passed to the macro process.

_name_The name of the macro.

_parameters_The parameters passed to the macro.

Type Parameters

T
Type of user item being passed to the macro process.

Return Value

A string that represents the macro.

Example

This example adds two macros to the macro processor and processes a string.

using Leadtools.Dicom.Common.Anonymization; public void MacroProcessorSample() { MacroProcessor<object> processor = new MacroProcessor<object>(); // // add two macros to the macro processor // processor.Macros.Add("current_date", new MacroSubstitutionDelegate<object>(CurrentDateMacro)); processor.Macros.Add("current_time", new MacroSubstitutionDelegate<object>(CurrentTimeMacro)); // // Process a macro string // Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}")); } private string CurrentDateMacro(object userData, string name, params object[] parameters) { return DateTime.Now.ToShortDateString(); } private string CurrentTimeMacro(object userData, string name, params object[] parameters) { return DateTime.Now.ToShortTimeString(); }

Leadtools.Dicom.Common Assembly